from hello_shunzhi.hello_teacher import hello_student
hello_student.hello('叶权华')

# 该函数中实现读取文件score.txt,并计算平均分，score.txt中每一行表示一个分数数据，要求:过滤掉不合法的分数
def computeScore(file_path):
    total_score = 0
    count = 0
    with open('score.txt', 'r') as file:
        for line in file:
            try:
                score = float(line.strip())
                if 0 <= score <= 100:  # 假设合法分数范围为0到100
                    total_score += score
                    count += 1
                else:
                    print(f"Illegal score found: {score}. Skipping.")
            except ValueError:
                print(f"Invalid score format: {line.strip()}. Skipping.")

    if count > 0:
        average_score = total_score / count
        return average_score
    else:
        return 0  # 如果没有合法的分数，则返回0或者其他你认为合适的值


file_path = "score.txt"  # 请将文件路径替换为实际的文件路径
average = computeScore(file_path)
print(f"The average score is: {average}")
# 请确保将file_path替换为实际的文件路径。这个函数将逐行读取文件中的分数，将合法的分数累加起来，并计算平均分数。
# 同时，它会过滤掉不合法的分数，并打印相应的警告信息




